package com.linln.modules.system.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.StatusUtil;
import com.linln.component.excel.annotation.Excel;
import com.linln.component.excel.enums.ExcelType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author 小懒虫
 * @date 2018/8/14
 */
@Data
@Entity
@Table(name = "pcs_patient_admission") // 修改: pcs_patient -> pcs_patient_admission
@ToString(exclude = {"dept", "roles"})
@EqualsAndHashCode(exclude = {"dept", "roles"})
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update pcs_patient_admission" + StatusUtil.SLICE_DELETE) // 修改: pcs_patient -> pcs_patient_admission
@Where(clause = StatusUtil.NOT_DELETE)
@Excel("患者住院记录") // 修改: 患者 -> 患者住院记录
public class PatientAdmission implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Excel(value = "ID", type = ExcelType.EXPORT)
    private Long id;

    @CreatedDate
    @Excel("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    @LastModifiedDate
    @Excel("更新时间")
    private Date updateTime;

    @JsonIgnore
    private Long createUser;

    @JsonIgnore
    private Long updateUser;

    @Excel("病床号")
    private String bedNo; // 新增字段

    @Excel("病区")
    private String depId; // 新增字段

    @Excel("病区名称")
    private String depName;

    @Excel("手机号")
    private String phone; // 新增字段

    @Excel("患者id")
    private Long patientId; // 新增字段

    @Excel("入院时间")
    private String admissionTime; // 新增字段

    @Transient
    private String admissionTimeStr;


    @Excel("出院时间")
    private String dischargeTime; // 新增字段
    @Transient
    private String dischargeTimeStr;

    @Excel("账单号")
    private String orderNo; // 新增字段
    private String name;


    private Byte status = StatusEnum.OK.getCode(); // 新增字段
    private Byte admissionStatus; // 新增字段

    @Transient
    private Double amount;
    @Transient
    private List<Long> orderIds;
    //预缴金额
    private Double increase;
    //结算金额
    private Double reduce;
    //实际补缴金额
    private Double prepay;
    //结算时间
    private Date settledTime; // 新增字段

    //是否结算
    private Integer isSettled;
    //结算类型
    private Integer settledType;

    @Excel("患者id")
    private String patId;

    @Excel("患者住院登记ID")
    private String patInHosId;

    @Excel("患者住院号")
    private String patInHosCode;

    @Excel("存储住院信息")
    private String info;


    @Excel("已消费金额")
    @Transient
    private Double usedMoney; // 新增字段

    @Excel("余额")
    @Transient
    private Double total; // 新增字段

    @Excel("余额")
    @Transient
    private Double refundMoney; // 新增字段

    @Transient
    List<Order> orderList;

    @Transient
    List<TempParam> tempParamList;

}
